Registering a component in the script system

To refer to our component from the script, it is necessary to register its class, its properties, and methods in the script system. The register code, according to the agreement accepted in FastReport, may be placed in a file with a name similar to the name of the file with the component's code, adding the RTTI suffix (for example, frxBitBtnRTTI.pas in our case). See more about registration of classes, their methods and properties in the FastScript script library's documentation.

uses fs_iinterpreter, frxBitBtn, frxClassRTTI;

type

TFunctions = class (TObject)

public

constructor Create;

destructor Destroy; override;

end;

var

Functions: TFunctions;

constructor TFunctions.Create;

begin

{ fsGlobalUnit is a variable defined in the fs_iinterpreter unit. It contains the description }

{ of all classes, methods, types, variables etc. are registered in the script system }

with fsGlobalUnit do

begin

AddedBy := Self;

{ register a class, and then define its parent }

AddClass(TfrxBitBtnControl, 'TfrxDialogControl');

{ if there are several common controls in your unit, they can be registered right here }

{ for example, AddClass(TfrxAnotherControl, 'TfrxDialogControl'); }

AddedBy := nil ;

end;

end;

destructor TFunctions.Destroy;

begin

if fsGlobalUnit <> nil then

fsGlobalUnit.RemoveItems(Self);

inherited;

end;

initialization

Functions := TFunctions.Create;

finalization

Functions.Free;

end.